home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
4_0
/
UUPC3
/
MAC_SPEC
/
UNIX_LIB
/
SPLITNAM.C
< prev
Wrap
Text File
|
1988-03-10
|
626b
|
47 lines
/* splitname
split and and copy directory and filename from
pathname to dir and name
*/
splitname( path, dir, name )
char * path;
char * dir;
char * name;
{
register char *cp;
register int i;
strcpy( dir, path );
i = strlen( dir);
cp = dir + i;
while ((i-- > 0) && (*--cp != '/') && (*cp != ':') );
if (*cp == '/') cp++;
else if (*cp == ':') cp++;
strcpy( name, cp );
*cp = '\0';
}
#ifdef TEST
#include <stdio.h>
main ()
{
char buf[100];
char dir[100], name[100];
while (gets( buf ) != NULL ) {
splitname( buf, dir, name );
printf( "%s -> \"%s\" \"%s\"\n", buf, dir, name );
}
}
#endif